﻿///////////////////////////////////////////////////////////////////////////////
// Copyright 2016 lingzimaike@gmail.com
// GPLv2
// Author: lingzimaike
///////////////////////////////////////////////////////////////////////////////

#ifndef PAPA_NET_SOCKET_EVENT_HANDLER_H_
#define PAPA_NET_SOCKET_EVENT_HANDLER_H_

#include <papa/base.h>

namespace papa {
namespace net {

	class TcpSocket;
	class SocketEventHandler
	{
	public:
		SocketEventHandler(void) : tcp_socket_(0) {}
		virtual ~SocketEventHandler(void) {}
		TcpSocket& peer(void) const { return *tcp_socket_; }

		virtual void OnOpen(void) = 0;
		virtual void OnRead(void) = 0;
		virtual void OnWrite(void) = 0;
		virtual void OnTimeout(void) {}
		virtual void OnEOF(void) {}
		virtual void OnError(void) {}
		virtual void OnClose(void) {}

	private:
		friend class TcpSocket;

		TcpSocket* tcp_socket_;

		PAPA_DISALLOW_COPY_AND_ASSIGN(SocketEventHandler)
	};

}}  // namespace papa::net

#endif // PAPA_NET_SOCKET_EVENT_HANDLER_H_
